package gdut.imis.controller;

import gdut.imis.Utils.Result;
import gdut.imis.domain.Matches;
import gdut.imis.service.MatchesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author JiaFu
 * @Date 2023/4/8 18:37
 */
@RestController
@RequestMapping("/matches")
@Api(value = "比赛档案接口", tags = {"比赛档案接口"})
@RequiredArgsConstructor
public class MatchesController extends BaseController {
    private final MatchesService matchesService;

    @ApiOperation("新增比赛档案")
    @PostMapping("/addMatches")
    @PreAuthorize("@cp.hasPermission('matches')")
    public Result addMatches(@RequestBody Matches matches) {
        return matchesService.addMatches(matches);
    }

    @ApiOperation("根据学生id查询学生第一次参加比赛的档案回忆录")
    @GetMapping("/getMatchesMemoryByStuId/{studentId}")
    public Result getMatchesMemoryByStuId(@PathVariable("studentId") Long studentId){
        return matchesService.getMatchesMemoryByStuId(studentId);
    }

}
